package com.jye.cloud.user.controller;




import com.jye.cloud.Constants.MyConstants;
import com.jye.cloud.domain.Follow;
import com.jye.cloud.user.service.FollowService;
import com.jye.cloud.domain.JsonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/follow")
@Api(tags="关注控制器API")
public class FollowController {

    @Autowired
    FollowService followService;


    @PostMapping(value="/doCoursesFollow")
    @ApiOperation(value="关注课程", notes="需要3个参数,用户id:uId,父id:pId,状态:status", httpMethod = "POST")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType="query",name = "follow",
                    value = "follow实体类", required = true,
                    dataType = "Integer"),
    })
    public JsonResult doCoursesFollow(  Follow follow){
        JsonResult jsonResult = new JsonResult();
        //课程类别
        int taskType = MyConstants.followType.courseType;
        follow.setType(taskType);
        int i = followService.doFollow(follow);
        if(i==1){
            jsonResult.setMsg("关注成功!");
        }else {
            jsonResult.setMsg("关注失败!");
        }
        return jsonResult;
    }





}
